local dsp = require "luci.dispatcher"
require("luci.http")

m = Map("hsion_mLink",
	translate("MultiLink"))

--左下角返回至概况按钮
m.redirect = dsp.build_url("admin/network/hsion_mLink")

s = m:section(NamedSection, arg[1], "interface", translate("Interface"))
s.anonymous = true
s.addremove = false

--description
o = s:option(Value, "description", translate("Device Description"))
o.placeholder = translate("Device Description")

--interface
o = s:option(Value, "net", translate("Network"))
o.template = "cbi/network_ifacelist"
o.rmempty = false

--weight
o = s:option(Value, "weight", translate("Weight"))
o.datatype = "uinteger"
o.rmempty = false

--track_ip
o = s:option(MultiValue, "track_ip", translate("Track IP"))
o.datatype = "ip4addr"
o.rmempty = false

--count
o = s:option(Value, "count", translate("Ping Count Each Track IP"), translate("Range: 1-3"))
o.datatype = "range[1,3]"
o.rmempty = false
o.default = 1

--up
o = s:option(Value, "up", translate("Up"))
o.rmempty = false
o.default = 3

--down
o = s:option(Value, "down", translate("Down"))
o.rmempty = false
o.default = 3

--ping timeout
o = s:option(Value, "timeout", translate("Ping Timeout"), translate("Seconds"))
o.rmempty = false
o.datatype = "uinteger"

--ping timeout
o = s:option(Value, "interval", translate("Ping Interval"), translate("Seconds"))
o.rmempty = false
o.datatype = "uinteger"

local apply = luci.http.formvalue("cbi.apply")
if apply then
    luci.sys.exec("killall -9 hsion_mLink")
	luci.sys.exec("/etc/init.d/hsion_mLink start > /dev/null 2>&1 &")
end

return m
